// AWTContainer.h: interface for the AWTContainer class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_AWTCONTAINER_H__1434121B_3D94_11D2_A3EF_006097A44215__INCLUDED_)
#define AFX_AWTCONTAINER_H__1434121B_3D94_11D2_A3EF_006097A44215__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

//#include "AWTComponent.h"
#include "AWTLayoutManager.h"

interface AWTLayoutManager;
class AWTLayout;
class AWTComponent;

class AFX_EXT_CLASS AWTContainer : public AWTComponent  
{
DECLARE_DYNAMIC(AWTContainer)
public:
	AWTContainer();
	virtual ~AWTContainer();

	int getComponentCount()
		{return countComponents();}
	int countComponents()
		{return m_ncomponents;}
	AWTComponent* getComponent(int n);
	void getComponents(CObArray* pa)
		{pa->Copy(m_components);}
	virtual AWTInsets getInsets()
		{return insets();}
	virtual AWTInsets insets()
		{return m_insets;}
	AWTComponent* add(AWTComponent* comp)
		{addImpl(comp, CString(""), -1); return comp;}
	AWTComponent* add(LPTSTR name, AWTComponent* comp)
		{addImpl(comp, CString(name), -1); return comp;}
	AWTComponent* add(CString name, AWTComponent* comp)
		{addImpl(comp, name, -1); return comp;}
	AWTComponent* add(AWTComponent* comp, int index)
		{addImpl(comp, CString(""), index); return comp;}
//	AWTComponent* add(AWTComponent* comp, CObject* constraints)
//		{addImpl(comp, constraints, -1); return comp;}
	AWTComponent* add(AWTComponent* comp, CString constraints, int index)
		{addImpl(comp, constraints, index); return comp;}
	void remove(int index);
	void remove(AWTComponent* comp);
	void removeAll();
//  void setLayout(AWTLayoutManager* mgr);
//  void setLayout(AWTObject* mgr);
  virtual void setLayout(AWTLayout* mgr);
	AWTLayoutManager* getLayout()
		{return m_layoutManager != NULL ? m_layoutManager->getLayoutManager() : NULL;}
	virtual CWnd* createComponent()
		{return NULL;}
	virtual void doLayout();
	virtual void validate();
	virtual void validateTree();
	virtual void removeNotify();
	virtual void addNotify();
	virtual CSize getMinimumSize()
		{return minimumSize();}
	virtual CSize minimumSize();
	virtual CSize getPreferredSize()
		{return preferredSize();}
	virtual CSize preferredSize();
	virtual BOOL isContainer()
		{return TRUE;}
	virtual void transferFocus(AWTComponent* base) 
		{nextFocus(base);}
	virtual void nextFocus(AWTComponent* base);
//	virtual void componentAdded(AWTComponent* comp);

	virtual void eraseBackground(CDC* pDC);

protected:
	void addImpl(AWTComponent* comp, CString& constraints, int index);

	int m_ncomponents;
	CObArray m_components;
//	AWTLayoutManager* m_layoutManager;
	AWTLayout* m_layoutManager;
//	AWTObject* m_layoutManager;
//	CSize m_maxSize;
	AWTInsets m_insets;

};

#endif // !defined(AFX_AWTCONTAINER_H__1434121B_3D94_11D2_A3EF_006097A44215__INCLUDED_)
